/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package labb3;

import java.awt.Dimension;
import javax.swing.*;

    class inputDialog{
    String player, hostName;
    int portNr;
      inputDialog(){

      JTextField playerName = new JTextField(20);
      JTextField host = new JTextField(20);
      JTextField port = new JTextField(10);

      JPanel panel = new JPanel();
      panel.setPreferredSize(new Dimension(300,100));
      panel.add(new JLabel("Ditt namn:"));
      panel.add(playerName);
      panel.add(Box.createHorizontalStrut(15)); // a spacer
      panel.add(new JLabel("Server:"));
      panel.add(host);
      panel.add(new JLabel("Port:"));
      panel.add(port);
      
      int result = JOptionPane.showConfirmDialog(null, panel, 
               "Mata in ditt namn, serveradressen och portnumret.", JOptionPane.OK_CANCEL_OPTION);
      if (result == JOptionPane.OK_OPTION) {
         player = playerName.getText();
         if(host.getText().equals("")){
            hostName = "gru-ld03.csc.kth.se";
         } else {
            hostName = host.getText();
         }
         if(port.getText().equals("")){
            portNr = 4713;
         } else {
            portNr = Integer.parseInt(port.getText()); 
         }
         
      }
      }
}